package org.wzy.xmlg_backend.service.impl;

import org.wzy.xmlg_backend.mapper.EmpMapper;
import org.wzy.xmlg_backend.service.IEmpStatisticsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@Service
public class EmpStatisticsServiceImpl implements IEmpStatisticsService {

    @Autowired
    private EmpMapper empMapper;

    @Override
    public Map<String, Long> countByGender() {
        return empMapper.countByGender()
                .stream()
                .collect(Collectors.toMap(
                        map -> (String) map.get("gender"),
                        map -> (Long) map.get("count")
                ));
    }

    @Override
    public List<Map<String, Object>> countByJob() {
        return empMapper.countByJob();
    }

    @Override
    public List<Map<String, Object>> countByDept() {
        return empMapper.countByDept();
    }

    @Override
    public List<Map<String, Object>> countByEntryYear() {
        return empMapper.countByEntryYear();
    }
}